import 'package:flutter/material.dart';

// 知识点: 异步编程
// 创建无状态Widget Loading
class Loading extends StatelessWidget {
  const Loading({super.key});

  final bool isrunning = false;

  void getData() async {
    // 延迟3s打印
    await Future.delayed(Duration(seconds: 3), () {
      print("3s getData...");
    });
    print("getData after...");
  }

  @override
  Widget build(BuildContext context) {
    // 异步操作 打印结果是: "Loading页面被构建了" =》 "3s getData..." =》 "getData after..."
    getData();
    print("Loading页面被构建了");

    return Scaffold(
      body: Center(
        child: Text(
            "加载中",
            style: TextStyle(
              fontSize: 30.0
            )
        ),
      ),
    );
  }
}
